default_platform(:ios)

platform :ios do

  lane :test do
    cocoapods(podfile: "./Example/Podfile")
    scan(
	    workspace: "./Example/SwipeableTabBarController.xcworkspace",
	    scheme: "SwipeableTabBarController-Example",
	    device: "iPhone X"
    )
  end

  desc "Release a new version with a patch bump_type"
  lane :patch do
    release("patch")
  end

  desc "Release a new version with a minor bump_type"
  lane :minor do
    release("minor")
  end

  desc "Release a new version with a major bump_type"
  lane :major do
    release("major")
  end

  def release(type)
    pod_lib_lint(allow_warnings: true)
    podspec_name = "SwipeableTabBarController.podspec"
    version = version_bump_podspec(path: podspec_name,
                                   bump_type: type)
    increment_version_number(version_number: version)
    #cocoapods
    git_add
    git_commit(path: ".",
               message: "#{version} release")
    add_git_tag(tag: "#{version}")
    push_to_git_remote
    pod_push(allow_warnings: true)
  end
end
